﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

namespace U9BJWebApi.Public
{
    public static class LogManager
    {
        public static void WriteLog(string msg, string doctype)
        {
            try
            {
                string logFile = doctype;
                string filename = $"debug_{logFile}_" + DateTime.Now.ToString("yyyyMMdd") + ".Log";
                string path = $"{AppDomain.CurrentDomain.BaseDirectory}\\Logs";

                if (!Directory.Exists(path))
                    Directory.CreateDirectory(path);
                System.IO.StreamWriter sw = File.AppendText($"{path}\\{filename}");
                sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss: ") + " " + msg);
                sw.Close();
            }
            catch
            { }
        }
    }
}